package com.treasure.hunt.api

import com.module.lemlin.mode.SubscribeListener
import com.module.lemlin.rxhttp.HttpServiceData
import com.treasure.hunt.api.subscribe.subscribe
import com.treasure.hunt.entity.*
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
import io.reactivex.rxjava3.disposables.Disposable
import rxhttp.RxHttp
import rxhttp.wrapper.entity.Progress
import java.io.File


/**
 * 意见反馈
 * 类型:1=bug反馈,2=产品建议
 * */
fun otherAddFeedback(
    content: String, type: Int, listener: SubscribeListener<HttpServiceData>
): Disposable = subscribe(
    RxHttp.postForm("/api/index/add_feedback")
        .add("content", content)
        .add("type", type)
        .asClass(HttpServiceData::class.java)
    , listener
)

/**
 * 意见反馈
 * user_agreement=用户协议,privacy_policy=隐私政策,ordinary_video_rule=普通寻宝规则,luxury_video_rule=豪华寻宝规则,lucky_video_rule=幸运翻牌规则,turntable_video_rule=九色格规则,service_mobile=客服电话
 * */
fun otherGetConfig(
    name: String, listener: SubscribeListener<OtherConfigResponse>
): Disposable = subscribe(
    RxHttp.get("/api/index/get_config")
        .add("name", name)
        .asClass(OtherConfigResponse::class.java)
    , listener
)

/**
 * 意见反馈
 * user_agreement=用户协议,privacy_policy=隐私政策,ordinary_video_rule=普通寻宝规则,luxury_video_rule=豪华寻宝规则,lucky_video_rule=幸运翻牌规则,turntable_video_rule=九色格规则,service_mobile=客服电话
 * */
fun otherGetConfig2(
    name: String, listener: SubscribeListener<OtherConfigResponse>
): Disposable = subscribe(
    RxHttp.get("/api/index/get_config")
        //.setAssemblyEnabled(false)
        .add("name", name)
        .asClass(OtherConfigResponse::class.java)
    , listener
)

/**
 * 获取图片
 *invit_friends_to_share_wx=微信分享图,invit_friends_to_share_qq=QQ分享图,cart_give_image=增卡片分享图,daily_image=日奖图片
 * */
fun otherGetImage(
    name: String, listener: SubscribeListener<OtherImageResponse>
): Disposable = subscribe(
    RxHttp.get("/api/index/get_image")
        .add("name", name)
        .asClass(OtherImageResponse::class.java)
    , listener
)

/**
 * 分享海报
 * */
fun otherShareImage(
    type: String, cartId: String, listener: SubscribeListener<OtherUrlResponse>
): Disposable = subscribe(
    RxHttp.get("/api/index/share_image")
        .add("type", type)
        .add("cart_id", cartId)
        .asClass(OtherUrlResponse::class.java)
    , listener
)

/**
 * APP版本更新
 * */
fun otherGetVersion(
    version: String, listener: SubscribeListener<OtherAppResponse>
): Disposable = subscribe(
    RxHttp.postForm("/api/index/get_version")
        .add("version", version)
        .asClass(OtherAppResponse::class.java)
    , listener
)

/**
 * 獲取邀請好友列表
 * */
fun otherGetFriendsList(
    listener: SubscribeListener<BuddyResponse>
): Disposable = subscribe(
    RxHttp.postForm("/api/user/get_friends_list")
        .asClass(BuddyResponse::class.java)
    , listener
)


///**
// * 下载文件
// * @param file 文件
// * */
//fun commonUpload(
//    destPath: String, downloadurl:String,progress: UploadProgress? = null, listener: SubscribeListener<UploadResponse>
//): Disposable = subscribe(
//    RxHttp.get("/api/common/upload")
//        .addFile("file", file)
//        .upload(AndroidSchedulers.mainThread()) {
//            progress?.onProgress(it)
//        }
//        .asClass(UploadResponse::class.java)
//    , listener
//)
//
//interface UploadProgress {
//    fun onProgress(progress: Progress)
//}

